<?php


namespace App\Http\Controllers\cms;


use App\Engine\BaseController;
use App\Engine\map\Map;
use App\Models\House as HouseModel;
use function app\Utils\go;

class House extends BaseController
{
    public function get()
    {
        $res=HouseModel::with(['types','projects'])->orderBy('id','desc')->get();
        return go($res);

    }

    public function insert()
    {
        $res=HouseModel::create($this->post);
        return go($res);
    }

    public function update()
    {
        $res=HouseModel::find($this->post['id'])->update($this->post);
        return go($res);
    }

    public function del()
    {
        $res=HouseModel::destroy($this->get['id']);
        return go($res);
    }

    /**经纬度获取详细地址（API高德地图接口）
     * @return array
     */
    public function regeo()
    {
        return go((new Map())->regeo($this->post['position']));
    }
}
